SCRIPT_PATH = debug.getinfo(1).source:sub(debug.getinfo(1).source:find(".*\\")):sub(2)
player = GetMyHero()
dofile(SCRIPT_PATH .. "Common/3DTo2D.lua")
local camps = {
    bottomBlue = {
        respawnTime = 0,
        creeps = { { name = "AncientGolem1.1.1", active = true }, { name = "YoungLizard1.1.2", active = true  }, { name = "YoungLizard1.1.3", active = true  } },
        respawn = 300,
        position = {x = 3181, z = 7900},
    },
    bottomRed = {
        respawnTime = 0,
        creeps = { { name = "LizardElder4.1.1", active = true  }, { name = "YoungLizard4.1.2", active = true  }, { name = "YoungLizard4.1.3", active = true  } },
        respawn = 300,
        position = {x = 7600, z = 3517},
        },
    bottomWolves = {
        respawnTime = 0,
        creeps = { { name = "GiantWolf2.1.3", active = true  }, { name = "wolf2.1.1", active = true  }, { name = "wolf2.1.2", active = true  } },
        respawn = 60,
        position = {x = 3335, z = 6164},
        },
    bottomWraiths = {
        respawnTime = 0,
        creeps = { { name = "Wraith3.1.1", active = true  }, { name = "LesserWraith3.1.2", active = true  }, { name = "LesserWraith3.1.3", active = true  }, { name = "LesserWraith3.1.4", active = true  } },
        respawn = 50,
        position = {x = 6671, z = 4913},
    },
    bottomGolems = {
        respawnTime = 0,
        creeps = { { name = "Golem5.1.2", active = true  }, { name = "SmallGolem5.1.1", active = true  }, },
        respawn = 60,
        position = {x = 8173, z = 2515},
    },
    topBlue = {
        respawnTime = 0,
        creeps = { { name = "AncientGolem7.1.1", active = true  }, { name = "YoungLizard7.1.2", active = true  }, { name = "YoungLizard7.1.3", active = true  } },
        respawn = 300,
        position = {x = 10917, z = 6612},
    },
    topRed = {
        respawnTime = 0,
        creeps = { { name = "LizardElder10.1.1", active = true  }, { name = "YoungLizard10.1.2", active = true  }, { name = "YoungLizard10.1.3", active = true  } },
        respawn = 300,
        position = {x = 6430, z = 11008},
    },
    topWolves = {
        respawnTime = 0,
        creeps = { { name = "GiantWolf8.1.3", active = true  }, { name = "wolf8.1.1", active = true  }, { name = "wolf8.1.2", active = true  } },
        respawn = 60,
        position = {x = 10591, z = 8530},
    },
    topWraiths = {
        respawnTime = 0,
        creeps = { { name = "Wraith9.1.1", active = true  }, { name = "LesserWraith9.1.2", active = true  }, { name = "LesserWraith9.1.3", active = true  }, { name = "LesserWraith9.1.4", active = true  } },
        respawn = 50,
        position = {x = 7463, z = 9640},
    },
    topGolems = {
        respawnTime = 0,
        creeps = { { name = "Golem11.1.2", active = true  }, { name = "SmallGolem11.1.1", active = true  }, },
        respawn = 60,
        position = {x = 5768, z = 11928},
    },
    dragon = {
        respawnTime = 0,
        creeps = { { name = "Dragon6.1.1", active = true  }, },
        respawn = 360,
        position = {x = 9821, z = 4728},
    },
    baron = {
        respawnTime = 0,
        creeps = { { name = "Worm12.1.1", active = true  }, },
        respawn = 420,
        position = {x = 4439, z = 10082},
    },
}

function OnDraw()
    for k, camp in pairs(camps) do
        if os.clock() > camp.respawnTime then
            for l, creep in pairs(camp) do
                 if not creep.active then creep.active = true end
            end
        else
            local x, y = get2DFrom3D(camp.position.x, player.y + 150, camp.position.z + 60)
            local min = math.floor((camp.respawnTime - os.clock()) / 60)
            local sec = math.floor((camp.respawnTime - os.clock()) - min * 60)
            local t = "respawn in " .. min .. " : " .. (sec < 10 and ("0" .. sec) or sec)
            DrawText(t, 15, x, y, 0xFFFFFFFF)
        end
    end
end

function OnDeleteObj(object)
    if object ~= nil then
        for k, camp in pairs(camps) do
            local campActive = false
            for l, creep in pairs(camp) do
                if creep.name == object.name then creep.active = false end
                if creep.active then campActive = true end
            end
            if not campActive and camp.respawnTime<os.clock() then      --check
                camp.respawnTime = os.clock()+camp.respawn
            end
        end
    end
end

function OnLoad()
    local function getMapName()
    for i = 1, objManager.maxObjects, 1 do
        object = objManager:getObject(i)
        if object ~= nil and object.name == "Turret_OrderTurretShrine" then
            local x = object.x
            if x > 0 then return "Dominion"
            elseif x > -300 and x < 0 then return "Summoners Rift"
            elseif x < -300 then return "The Twisted Treeline"
            end
        end
    end
    return "UNKNOWN"
    end
    if getMapName~="Summoners Rift" then
        OnDeleteObj = function() end
        OnDraw = function() end
    end
end